package com.yuelao.yuelao_backend.controller;

import com.yuelao.yuelao_backend.common.ApiResponse;
import com.yuelao.yuelao_backend.common.ConfigConstants;
import com.yuelao.yuelao_backend.dto.DailyActionStatsDTO;
import com.yuelao.yuelao_backend.dto.UserDTO;
import com.yuelao.yuelao_backend.entity.User;
import com.yuelao.yuelao_backend.service.DailyActionRecordService;
import com.yuelao.yuelao_backend.service.UserService;
import com.yuelao.yuelao_backend.util.UserContextUtil;
import jakarta.annotation.Resource;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
@RequestMapping("/recommend")
@Slf4j
public class RecommendController {

    @Resource
    private UserService userService;

    @Resource
    private DailyActionRecordService dailyActionRecordService;



    /**
     * 获取推荐用户列表
     * GET /recommend/users
     * @return 推荐用户列表
     *
     */
    @GetMapping("/users")
    public ApiResponse<List<UserDTO>> getRecommendUsers() {
        // 获取当前登录用户
        Long currentUserId = UserContextUtil.getCurrentUserId();
        User user = userService.getById(currentUserId);

        DailyActionStatsDTO stats = dailyActionRecordService.getTodayStats(currentUserId, user.getIsVip());
        // 获取剩余可喜欢次数
        int size = stats.getLikeLimit()-stats.getLikeCount();
        List<UserDTO> recommendUsers = userService.getRecommendUsers(1, size);
        return ApiResponse.ok(recommendUsers);
    }
}